import { CpcBase, ICpcBaseIos } from "../../base/CpcBase";

const ios: ICpcBaseIos = {
    disableNextOutput: true,
    inputs: [
        {
            name: "data",
            type: 0,
        },
    ],
    outputs: [],
};
export class ResponseSuccess extends CpcBase {
    public title = "响应成功";

    public color = "rgba(0,200,0,0.5)";

    public type = "ResponseSuccess";

    public properties = {
        code: 200,
        message: "成功!",
    };

    constructor(title?: string) {
        super(ios, title);
        this.addWidget("text", "code", this.properties.code, undefined, { property: "code" });
        this.addWidget("text", "message", this.properties.message, undefined, { property: "message" });
    }

    protected codeEditDbShow: boolean = true;

    protected codeEidtReadOnly: boolean = false;

    cpcRunCode(preDatas: any[], inputInfos: any[], outputInfos: any[]): any[] {
        const result = {
            code: this.properties.code,
            message: this.properties.message,
            data: preDatas[0],
        };
        console.log("响应失败打印输出", result);
        return [result];
    }
}
